package org.ddd.specification.catalog.collection;

import java.util.Collection;

import org.ddd.specification.catalog.AbstractSpecification;

/**
 * Specification that checks if an object is contained inside a collection.
 * 
 * @author Jeroen van Schagen
 * @since 12-03-2011
 */
public class ContainsSpecification extends AbstractSpecification<Collection<?>> {
    private final Object target;

    /**
     * Construct a new {@link ContainsSpecification}.
     * @param target the object we are searching for in candidate collections
     */
    public ContainsSpecification(Object target) {
        this.target = target;
    }

    /**
     * {@inheritDoc}
     * @see Collection#contains(Object)
     */
    @Override
    public boolean isSatisfiedBy(Collection<?> candidate) {
        return candidate.contains(target);
    }
}
